## Loading required package: pacman
Introduction of the research and introduction research questions
Ever heard of the game FIFA by EA? It is the most popular football game in the world played by millions. So to get the correct trajectory for the ball is one of the most important aspects of the game. If the trajectory is not realistic it wouldn’t be as good of a game as it is now. One of the ways to get the correct trajectory is calculating it using a model with different forces acting on the ball. Think of things like speed, gravity and air resistance. By accurately modelling these forces, we can predict the path of a football. This is essential for things like video games but also for predicting paths of different things or projectiles.
So in this report the aim is to provide a model that models the trajectory of a football. This will be done using different physics formulas modelling the forces at play like speed, gravity and air resistance. Furthermore the specific parameters that must be chosen to accurately model these forces will be examined and explained.
With all this in mind the question is, how can the trajectory of a football be accurately modelled using the different forces at play?
As you might have guessed the goal is to model the trajectory of a football that is kicked by someone. This is done by calculating the different forces at play on any given moment. The forces chosen to model are velocity, acceleration and the Magnus force. With these three the ball’s position can be calculated for any given moment. The formulas for these three will be explained further in the theory section. In the results different starting parameters will be used to showcase multiple paths of a football using tools like Plotly to visualize the trajectories. The expectation is that this model will show a realistic trajectory of a football considering the effects of the different forces.
To understand this model a little knowledge about basic physics can be useful, here is a small explanation about the forces. So everywhere around you there are different forces at play. One of the important forces is the air resistance experienced with most outside activities like running, cycling and even walking. For example with running you have to use energy to move forward, this is translated to force by your muscles. While moving you push the air out of the way and to do so the force you generate must be higher than the air resistance. If it is windy outside it takes more energy to move the same distance because the air exerts a higher force on you. So lets take a look at al the forces on a football. Air resistance is one of them of course, but also gravity and the Magnus force. All the forces on the ball are combined in different formulas. Velocity, Acceleration and a formula for the Magnus force. These three are split in a X-, Y-, Z-axis to calculate the forces in a 3D plane.
There are multiple forces that are interaction with the ball when u kick it. Things like gravity, acceleration and air resistance. But since the ball has a spin the magnus force comes in to play as well. This force deflects the ball in flight . The formula for the magnitude of the acceleration created by magnus force is the following.
\[ \overrightarrow{f} = \frac{8}{3} \pi \rho r^3\cdot\overrightarrow{\omega} \cdot \overrightarrow{V}\]
The constant:
\[ \lambda = \frac{8}{3} \pi \rho r^3 \]
Equals:
\[ \overrightarrow{f} = \lambda \cdot \begin{vmatrix} \overrightarrow{i} & \overrightarrow{j} & \overrightarrow{k}\\ \omega_{x} & \omega_{y} & \omega_{z} \\ V_{x} & V_{y} & V_{z} \end{vmatrix} \]
The \(\omega\) is the spin on the ball when kicked aka the angular velocity. The \(r\) stands for radius and \(\rho\) is the density of the ball. \(V\) stands for the velocity relative to the surrounding air. In the model we will implement the velocity for the general displacement of the ball in like the formula below.
\[ \frac{\delta V}{\delta t} = \sqrt{velocity_{x}^2 + velocity_{y}^2 + velocity_{z}^2} \] Now we solve the magnus displacement for each axis, first for x:\[ \frac{\delta\lambda_{x}}{\delta t} = \lambda \cdot (\omega_{y} \cdot V_{z}- \omega_{z} \cdot V_{y}) \cdot e^-\mu \]
Now for y:\[ \frac{\delta \lambda_{y}}{\delta t} = \lambda \cdot (\omega_{y} \cdot V_{z}- \omega_{z} \cdot V_{x}) \cdot e^-\mu \]
And for z:\[ \frac{\delta\lambda_{z}}{\delta t} = \lambda \cdot (\omega_{y} \cdot V_{x}- \omega_{x} \cdot V_{y}) \cdot e^-\mu \]
The speed of the ball slows down over time due to all acting forces on it. These forces are magnus force, air resistance and gravity. Now to add them all together. First for the vertical axis:
\[ \frac{\delta a_{z}}{\delta t} = \frac{-k \cdot V_{z} \cdot V + \lambda_{z} - m \cdot g}{m} \]
Here, \(k\) represents the air resistance, \(v_z\) the upward speed, \(V\) is the total speed on the ball, \(m\) is the total mass , \(g\) is the force of gravity and \(\lambda_z\) is the magnus.
Second the horizantal axis:
\[ \frac{\delta a_{x}}{\delta t} = \frac{-k \cdot V_{x} \cdot V + \lambda_{x} }{m} \]
Here, \(V_x\) is the horizontal speed and \(\lambda_x\) is the horizontal magnus force.
Third is the sideways direction:\[ \frac{\delta a_{y}}{\delta t} = \frac{-k \cdot V_{y} \cdot V + \lambda_{y}}{m} \]
Here, \(V_y\) is the sideways speed and \(\lambda_y\) is the magnus force in the sideways direction.
The deSolve library is used the solve the multiple differential equations in the model. These are mainly used to calculate the acceleration, velocity and position based on the different forces acting on the football. With a function in the deSolve library the model is run over a defined time and stored in a data frame. To visualize all the positions of the ball the library Plotly is used. This is a library to make interactive plots in R.
The model uses a lot of different parameters and constants as seen in the multiple formulas and the table below. Every parameter has a initial value and the constants have a constant value. In the table below every one of those is shown with a small description and the initial or constant value. Some parameters are used to simulate someone kicking a still football, these are v, angle.z, angle.y, angle.x and state_straight. These parameters are used to kick-start the model, otherwise the ball will not move.
Most of these parameters are self-explanatory and chosen based on typical physical characteristics of a football. And the others are mostly some constants and coefficients that are needed for the formulas. These are fixed and always the same, so these can be found online when searching for the formulas. All the parameters as well as the starting values are entered in the piece of R code shown under the table. These can later be used in the code that functions as the model, which will be discussed in the results.
| Variable/Parameter | Description | Value/Formula |
|---|---|---|
| r | Radius of the football | 0.11 m |
| rho | Air density | 1.29 \(kg/m^3\) |
| cw | Drag coefficient of the football | 0.5 |
| cm | Magnus coefficient | 1 |
| m | Mass of the football | 0.445 kg |
| k | Drag force coefficient | \(\frac{1}{2} \cdot cw \cdot \rho \cdot (\pi \cdot r^2)\) |
| mu | Friction coefficient | 0.1 |
| g | Gravitational acceleration | 9.81 \(m/s^2\) |
| km | Another coefficient | \(cm \cdot 8 \cdot \rho \cdot r^3\) |
| f | Force | 10 N |
| lambda | Magnus constant | \(\frac{8}{3} \pi \cdot r^3\) |
| e | Euler’s number | \(e \approx 2.71828\) |
| v | Initial velocity of the football | 30 |
| angle.z | Initial angle of the football’s trajectory (z-axis) | 25 degrees |
| angle.y | Initial angle of the football’s trajectory (y-axis) | 30 degrees |
| angle.x | Initial angle of the football’s trajectory (x-axis) | 7 degrees |
| state_straight | Initial state of the football | See code |
| times | Time steps | 0 to 10 with step size 0.01 |
In this section, the results of the simulation are shown. The model shows the trajectory of a football based on a calculation taking different forces, like drag, Magnus and gravitational, forces in to account.
In the piece of code below the formulas of these different forces are used to form the model. These are put in a R function simply named model. This function is used with the deSolve library to solve the differential equations and calculate the acceleration, velocity and angular velocity of the football on every time step. With these parameters every possible position can be calculated.
# performing simulation
out <- as.data.frame(ode(times = times,
y = state_straight,
parms = parameters,
func = model))
# filtering results
output <- subset(out, position.z >= 0)
# 2 dimensional fig of trajectory
plot(output$position.y,
output$position.z,
type = "l",
ylab = "Height in m",
xlab = "Length in m",
main = "Trajectory")
# dimensional representation
fig <- plot_ly(output,
x = ~position.x,
y = ~position.y,
z = ~position.z,
type = "scatter3d",
mode = "lines",
name = "Trajectory",
opacity = 1)
# adding goal
goal <- data.frame(x = c(-3.66,-3.66,3.66,3.66),
y = c(30,30,30,30),
z = c(0,2.44,2.44,0))
fig <- fig %>% add_trace(data = goal,
x = ~x,
y = ~y,
z = ~z,
mode = "lines",
name = "Goal")
# resizing plot
ratio <- max(output$position.z) / max(output$position.y)
fig <- fig %>% layout(scene = list(aspectratio = list(x = 1, y = 1, z = .4)))
fig
Discuss what your goal was, what the end result is and how you could continue working from here.
# variables & parameters
r <- 0.11
rho <- 1.29
cw <- 0.5
cm <- 1
parameters <- c(m = 0.445, k = (1/2) * cw * rho * (pi * r^2),
mu = 0.1, g = 9.81, km = cm * 8 * rho * r^3, f = 10,
lambda = 8/3*pi*r^3, e = exp(1))
# state of start
v <- 30
angle.z <- 25
angle.y <- 30
angle.x <- 7
state_straight <- c(velocity = c(x =6,
y = 37.5,
z = 11.5),
position = c(x = 0, y = 0, z = 0),
angular = c(x = 2,
y = -2,
z = 14))
# time steps
times <- seq(0, 10, by = 0.01)
# model
model <- function(t, y, parms){
with(as.list(c(y, parms)), {
# velocity & positioning
velocity <- c(velocity.x, velocity.y, velocity.z)
position <- c(position.x, position.y, position.z)
angular <- c(angular.x, angular.y, angular.z)
# Model for acceleration
V <- sqrt(velocity.x^2 + velocity.y^2 + velocity.z^2)
# Magnus force
lambda.z <- lambda * (angular.y*velocity.x- angular.x * velocity.y) * e^-mu
lambda.x <- lambda * (angular.y*velocity.z- angular.z * velocity.y) * e^-mu
lambda.y <- lambda * (angular.x*velocity.z- angular.z * velocity.x) * e^-mu
az <- (-k * velocity.z * V + lambda * (angular.y*velocity.x- angular.x * velocity.y) * e^-mu - m * g) / m
ax <- (-k * velocity.x * V + lambda * (angular.y*velocity.z- angular.z * velocity.y) * e^-mu) / m
ay <- (-k * velocity.y * V + lambda * (angular.x*velocity.z- angular.z * velocity.x) * e^-mu) / m
acc <- c(ax, ay, az)
return(list(c(acc, velocity, angular)))
}
)
}